{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "004d29b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7a41659f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'E:\\\\pycharm_out\\\\yufa\\\\git_test'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.path.abspath(\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "d6459690",
   "metadata": {},
   "outputs": [],
   "source": [
    "join_path = os.path.join('E:\\pycharm_out\\yufa\\git_test','main.py')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "7058745e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'E:\\\\pycharm_out\\\\yufa\\\\git_test\\\\main.py'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "0b8371a0",
   "metadata": {},
   "outputs": [],
   "source": [
    "split_path = os.path.split(os.path.abspath(''))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "42578a04",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('E:\\\\pycharm_out\\\\yufa', 'git_test')"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "split_path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "85b7383c",
   "metadata": {},
   "outputs": [],
   "source": [
    "split_path1, file_name = os.path.split(join_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "bd8cb25d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'E:\\\\pycharm_out\\\\yufa\\\\git_test'"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "split_path1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "e218c99b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'main.py'"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "file_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "42659f2d",
   "metadata": {},
   "outputs": [],
   "source": [
    "splitext_path, format_name = os.path.splitext(file_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "f5aacb82",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'main'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "splitext_path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "cb6385b2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'.py'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "format_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "c923ca1d",
   "metadata": {},
   "outputs": [],
   "source": [
    "dir_name = os.path.dirname(join_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "83ce36d6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'E:\\\\pycharm_out\\\\yufa\\\\git_test'"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dir_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "6fa27d7b",
   "metadata": {},
   "outputs": [],
   "source": [
    "dir_name1 = os.path.dirname(dir_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "a95a7dd4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'E:\\\\pycharm_out\\\\yufa'"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dir_name1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "16127732",
   "metadata": {},
   "outputs": [],
   "source": [
    "dir_path = os.path.exists(dir_name1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "22e377aa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dir_path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5fa38eb4",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
